# 定时任务,更新关键词信息
from apscheduler.schedulers.blocking import BlockingScheduler
from datetime import datetime
# 输出时间
def job():
    from service import searchLogService
    searchLogService.sogou_data = searchLogService.load_data('../static/history_2011_12_30.new.csv')

# 定时写入缓存更新数据库
def job_redis():
    from service import redisService
    redisService.redis_to_data()
# BlockingScheduler
scheduler = BlockingScheduler()
# 每周一晚上3点进行系统关键词优化 cron 为在某个确切的时间周期性的触发事件
scheduler.add_job(job, 'cron', day_of_week='1', hour=3, minute=0)
# 每周五晚上3点进行缓存持久化写入数据库
scheduler.add_job(job_redis, 'cron', day_of_week='5', hour=3, minute=0)
scheduler.start()